import Vue from 'vue'
import Router from 'vue-router'

/* *广告主首页模块   */
import advertiserIndex from "./advertiserIndex"
/* *广告主我的模块   * */
import advertiserMine from "./advertiserMine"
/**流量主-我的   */
import influenceMine from "./influenceMine"
/**流量主-登录模块   */
import influencerLogin from "./influencerLogin"
/**流量主-广场模块   */
import influencerSquare from "./influencerSquare" 
/**其他文件 模块   */
import otherRouter from "./otherRouter"

Vue.use(Router);

export default new Router({
  // mode: 'history',
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '*',
      redirect: '/infIndex/index',
    },  
    {
      path: '/help', // 帮助页面
      name: 'help',
      title:"帮助页面",
      component: resolve => { require(['@/views/helpTool/Help'], resolve) },
    },
    ...advertiserIndex,
    ...advertiserMine,
    ...influenceMine,
    ...influencerLogin,
    ...influencerSquare,
    ...otherRouter,
  ],
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
  // scrollBehavior (to, from, savedPosition) {
  //   return new Promise((resolve , reject) =>{
  //     if(savedPosition){
  //       setTimeout(() => {
  //         resolve(savedPosition)
  //       }, 50);
  //     }
  //   } )
  // }
})